package weaver.interfaces.cese.duss.action.fee;

import com.weaver.general.BaseBean;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.cese.duss.ceseutil.CostUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-10-23
 * @Description: 业务申请类型的流程接口
 * @ModifyLog:
 **/
/*
 *@Param:
 *@return:
 *@Author: Dusongsong
 *@Date: 2020/10/23
 */
public class WeaBusinessApplicatAction extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        RecordSet rs = new RecordSet();
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        writeLog( "----WeaBusinessApplicatAction-------" + requestid );
        try {
            String sql = "select id,yshd,sqrq,fykm,cblrzx,ysze from " + tablename + " where requestid=?";
            rs.executeQuery( sql, requestid );
            rs.writeLog( sql, requestid );
            rs.next();
            String yshd = Util.null2String( rs.getString( "yshd" ) );//预算活动
            String sqrq = Util.null2String( rs.getString( "sqrq" ) );//申请日期
            String fykm = Util.null2String( rs.getString( "fykm" ) );//费用科目
            String cblrzx = Util.null2String( rs.getString( "cblrzx" ) );//成本/利润中心
            String ysze = Util.null2String( rs.getString( "ysze" ) );//预算总额
            if (yshd != "") {
                String yslx = "0";//占用
                //业务申请信息插入到预算执行信息表
                CostUtil.deleteYszxxxb( requestid );
                CostUtil.insertYszxxxb( requestid, yshd, fykm, cblrzx, sqrq, ysze, yslx, sqrq );
            }
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            writeLog( "异常参考:" + e );
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "Action接口异常！" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }


}
